<script setup lang="ts">
import footerBtn from "@/components/footerBtn/index.vue";
import Cache from "@/utils/cache";
import { USER_INFO } from "@/config/cache";
import { useTheme } from "@/composables/useTheme";
import { onLoad, onReady, onShow } from "@dcloudio/uni-app";
import { setNotice } from "@/api/setting";
import saveUserInfoToLocation from "@/composables/saveUserInfoToLocation";
import { Tips } from "@/utils";
import { hidePageNavInWechatBrowser } from "@/composables/useHiddenNavbar";
import hideWechatMenu from "@/composables/hideWechatMenu";
onReady(() => {
  hidePageNavInWechatBrowser();
});
let notice_content = ref("");

onShow(() => {
  hideWechatMenu();
  try {
    const dataInfo = JSON.parse(Cache.get(USER_INFO));

    notice_content.value = dataInfo.notice_content;
  } catch (error) {}
});
const { colorStyle } = useTheme();
function submitHandler() {
  let params = { notice_content: notice_content.value };
  setNotice(params).then((res) => {
    saveUserInfoToLocation(res.data.business);
    Tips({ title: res.info }, { tab: 3 });
  });
  console.log("确认点击");
}
</script>
<template>
  <view class="wrap" :style="colorStyle">
    <view class="text_box">
      <view class="title">公告内容 <text class="red_class">(用于大屏报价盘展示)</text> </view>
      <view class="textarea_box">
        <textarea
          class="textarea_class"
          placeholder-class="placeholder_class"
          placeholder="请输入公告内容"
          v-model="notice_content"
        ></textarea>
      </view>
    </view>
    <view class="uni-p-b-98"></view>
    <footerBtn title="确认设置" @submitHandler="submitHandler" />
  </view>
</template>

<style scoped lang="scss">
.wrap {
  .text_box {
    border-radius: 14rpx;
    background: #fff;
    .title {
      //   height: 80rpx;
      //   line-height: 80rpx;
      padding-top: 20rpx;
      padding-left: 26rpx;
      color: rgba(39, 38, 54, 1);
      font-size: 30rpx;
      font-weight: bold;
      .red_class{
        font-size: 26rpx;
        color: #D43030;
        font-weight: normal;
      }
    }
    .textarea_box {
      padding: 20rpx;
      textarea {
        font-size: 30rpx;
      }
      .textarea_class {
        min-height: 100rpx;
        width: 100%;
      }
      .placeholder_class {
        color: #ccc;
      }
    }
  }
}
</style>
